      SUBROUTINE QUIKVIS5A2C2(REQMTMA,EVENTMA,BAR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE QUIKVIS PROGRAM.  IT IS USED TO LOAD THE
C 121-CHARACTER VARIABLE NAMED 'BAR' THAT IS USED TO DISPLAY TARGET
C AVAILABILITY FOR A SPECIFIC TIME, RAAN, AND THE COMPOSITE OF ALL
C OBSERVATION REQUIREMENTS.
C
C DEFINE A LINE 121 UNITS LONG.  MAKE EACH UNIT REPRESENT ONE MINUTE.
C THE FIRST AND LAST POSITIONS REPRESENT THE SAME VALUE AND ARE USED
C FOR EASIER READING.
C
C THE LINE SHOWS ELAPSED TIME IN MINUTES AFTER THE S/C CROSSES THE
C POINT AT WHICH THE EVENT SPECIFIED BY THE KRELTIME GLOBAL PARAMETER
C OCCURS.  PUT *'S IN BAR POSITIONS WHENEVER THE TARGET IS AVAILABLE(IE,
C SATISFIES ALL REQUIREMENTS).
C
C
C VARIABLE DIM TYPE I/O DESCRIPTION
C -------- --- ---- --- -----------
C
C REQMTMA       R*8  I  MEAN ANOMALY RANGES WHERE INDIVIDUAL REQMTS ARE
C      2,MAXREQMT       SATISFIED.  IN RADIANS.
C
C                       THERE ARE MAXREQMT REQUIREMENTS, BUT WHAT THEY
C                       ARE IS UNIMPORTANT IN THIS ROUTINE.
C
C                       REQMTMA(1,I) IS THE START VALUE WHERE THE I'TH
C                       REQUIREMENT IS SATISFIED, REQMTMA(2,I) IS THE
C                       END VALUE.
C
C EVENTMA   1   R*8  I  THE MEAN ANOMALY AT WHICH OCCURS THE ORBITAL
C                       EVENT FROM WHICH THE TIME BAR(BAR, BELOW) IS
C                       MEASURED.
C
C BAR       1 CH*121 O  121-CHARACTER STRING, EACH STRING ELEMENT BEING
C                       ASSOCIATED WITH A 1-MINUTE RANGE OF TIMES
C                       RELATIVE TO THE OCCURRENCE OF AN ORBITAL EVENT.
C
C                       THE FIRST ELEMENT REPRESENTS THE 0-1 RANGE, THE
C                       SECOND THE 1-2 RANGE, ETC.  THE 121'ST ELEMENT
C                       REPRESENTS THE SINGLE VALUE EQUAL TO THE
C                       NEAREST INTEGER TO THE PERIOD.
C
C                       IF THE ELEMENT IS '*', THE REQUIREMENT IS
C                       SATISFIED IN THAT ELEMENT'S RANGE.  IF BLANK, IT
C                       IS NOT SATISFIED.
C
C***********************************************************************
C
C BY C PETRUZZO/GFSC/742.   2/86.
C       MODIFIED.... 9/86. CJP. EXTENSIVE MODS TO REFLECT THE CHANGE
C                               FROM WORKING IN TRUE ANOMALY TO WORKING
C                               IN MEAN ANOMALY;  DELETION OF QUIKVIS5Z
C                               CALL(MOVED TO QUIKVIS5A FOR BETTER
C                               PROGRAM STRUCTURE);  MISC CODE AND
C                               COMMENT CHANGES TO REFLECT BUG
C                               CORRECTIONS OR BETTER CODE DESIGN.
C                    3/87. CJP. MODIFIED ANGLAP CALL TO REFLECT MOD TO
C                               ANGLAP CALLING SEQUENCE.
C
C***********************************************************************
C
      INCLUDE 'QUIKVIS.INC'
C
      REAL*8 REQMTMA(2,MAXREQMT),OVERLAP(2,MAXREQMT)
      REAL*8 TOLER/1.D-2/    ! SECONDS
      CHARACTER*121 BAR
C
      IBUG = 0
      LUBUG = 19
C
      IF(IBUG.NE.0) WRITE(LUBUG,1001) RAAN*DEGRAD,
     *   (I,REQMTMA(1,I)*DEGRAD,REQMTMA(2,I)*DEGRAD,I=1,MAXREQMT)
 1001 FORMAT(/,' QUIKVIS5A2C2 DEBUG. AT ENTRY.  RAAN=',G13.5/,
     *         (T5,'REQMT',I2,' REQMTMA=',2G13.5))
C
C
C INTIALIZE
C
      DELBAR = 60.D0       ! EACH BAR COVERS 60 SECONDS
      PD = DNINT(PERIOD)   ! USE A PERIOD THAT IS THE NEAREST INTEGER
      LASTBAR = JIDNNT(PD/DELBAR) + 1
C
C
C    PUT MARKERS IN BAR TO SHOW EVERY 10'TH MINUTE. (IF DELBAR IS
C    CHANGED, RETHINK THIS CODE)
      BAR = ' '  ! BE SURE BAR IS CLEAR BEFORE STARTING.
      DO I=1,LASTBAR,10
        BAR(I:I) = 'X'
        END DO
C
C
C FIND THE MEAN ANOMALY RANGES WHERE ALL REQMTS ARE SATISFIED.  REQMTMA
C PAIRS GIVE THE MEAN ANOMALY RANGES WHERE THE INDIVIDUAL REQUIREMENTS
C ARE SATISFIED.  THE TARGET IS AVAILABLE WHERE THE REQMTMA PAIRS
C OVERLAP.
C
C    FIND THE OVERLAPS
      CALL ANGLAP(REQMTMA,MAXREQMT,OVERLAP,MAXREQMT,NOVERLAP,LUERR,IERR)
C    ERROR SHOULD NEVER OCCUR.  STOP TO FORCE A LOOK AT WHY IT OCCURRED.
      IF(IERR.NE.0) STOP 'QUIKVIS5A2C2. ERROR STOP 1. SEE CODE.'
C
      IF(IBUG.NE.0) WRITE(LUBUG,1004) NOVERLAP,
     * (ISEG,OVERLAP(1,ISEG)*DEGRAD,OVERLAP(2,ISEG)*DEGRAD,
     *     ISEG=1,NOVERLAP)
 1004 FORMAT(' QUIKVIS5A2C2 DEBUG 1004. NOVERLAP=',I2/,
     *      ('    ISEG=',I2,'  TA IN/OUT=',2F8.2) )
C
C
C IF NO OVERLAPS OCCUR, THEN BAR REMAINS BLANK.  NO FURTHER PROCESSING
C IS NEEDED.
C
      IF(NOVERLAP.EQ.0) GO TO 9999
C
C
      IF(IBUG.NE.0) WRITE(LUBUG,1003)
     *    (ISEG,OVERLAP(1,I)*DEGRAD,OVERLAP(2,I)*DEGRAD,I=1,NOVERLAP)
 1003 FORMAT(
     *  ' QUIKVIS5A2C2 DEBUG 1003. MEAN ANOMS REL TO RAMERID CROSSING'/,
     * ('    ISEG,OVERLAP=',I2,2F9.3) )
C
C
C PUT *'S IN BAR WHEREVER THE OVERLAPS OCCUR.  TIME BEGINS WHEN THE
C ORBITAL EVENT OCCURS.
C
      DO ISEG=1,NOVERLAP
        DT1 = EQVANG(OVERLAP(1,ISEG)-EVENTMA) / TWOPI*PD
        DT2 = EQVANG(OVERLAP(2,ISEG)-EVENTMA) / TWOPI*PD
        IF(DT2.LT.DT1) DT2 = DT2 + PD
C
        DT = DT1 - DELBAR
        DO WHILE(DT.LT.DT2)
          DT = DT + DELBAR
          ICH = (DT+TOLER)/DELBAR + 1
          IF(ICH.NE.LASTBAR) THEN   ! THE LAST POSITION IS HANDLED LATER
            IF(ICH.GT.(LASTBAR-1)) ICH = ICH - (LASTBAR-1)
            BAR(ICH:ICH) = '*'
            END IF
          END DO  ! ENDS THE 'DO WHILE(DT.LT.DT2)' LOOP
C
C        FOR BARS THAT END ON OR CROSS THE PERIOD(=PD) POSITION, MAKE
C        SURE THE ZERO AND PERIOD POSITIONS ARE SET PROPERLY.
          IF(DABS(DT2-PD).LT.TOLER) BAR(LASTBAR:LASTBAR) = '*'
          IF(DT2.GT.(PD+TOLER)) THEN
            BAR(  1:  1) = '*'
            BAR(LASTBAR:LASTBAR) = '*'
            END IF
C
        END DO  ! ENDS THE 'DO ISEG' LOOP
C
C
 9999 CONTINUE
      RETURN
C
C***********************************************************************
C
C
C**** INITIALIZATION CALL. PUT GLOBAL PARAMETER VALUES INTO THIS
C     ROUTINE'S LOCAL VARIABLES.
C
      ENTRY QVINIT5A2C2
C
      CALL QUIKVIS999(-1,R8DATA,I4DATA,L4DATA)
      RETURN
C
C***********************************************************************
C
      END
